<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

namespace app\shop\validate;

use think\Validate;

/**
 * 行为验证器
 * @package app\admin\validate
 * @author 蔡伟明 <314013107@qq.com>
 */
class AddShop extends Validate
{
    //定义验证规则
    protected $rule = [

        'name|店铺名称' => 'require|unique:shop',
        'shoptype|店铺类型'   => 'require',
        //'ShopCategory|店铺经营类目' => 'require',
        'contacts|联系人' => 'require',
        'mobile|手机号'   => 'require|regex:^1[0-9]{10}$|unique:shop',
        'tel|固话'   => 'regex:0\d{2,3}-\d{5,9}|0\d{2,3}-\d{5,9}|unique:shop',
        'email|邮箱'     => 'require|email|unique:shop',
        'password|密码'  => 'require|length:6,20',
        'provinceid|省份' => 'require',
        'cityid|城市' => 'require',
    ];

    //定义验证提示
    protected $message = [
        'name.require' => '请输入店铺名称',
        'name.unique' => '店铺名称已存在',
        'shoptype.require'     => '请选择店铺类型',
       // 'ShopCategory.require'     => '请选择店铺经营类目',
        'contacts.require'=>'联系人不能为空',
        'mobile.regex'     => '手机号不正确',
        'mobile.require'     => '手机号不能为空',
        'mobile.unique'     => '手机号已存在',
        'tel.regex'     => '固话不正确',
        'tel.unique'     => '电话已存在',
        'email.require'    => '邮箱不能为空',
        'email.email'      => '邮箱格式不正确',
        'email.unique'     => '该邮箱已存在',
        'password.require' => '密码不能为空',
        'password.length'  => '密码长度6-20位',
        'provinceid.require'     => '请选择省份',
        'cityid.require'     => '请输入城市',
    ];
    //定义验证场景
    protected $scene = [
        //更新
        'update'  =>  ['name','shoptype','contacts','mobile','tel','email', 'password' => 'length:6,20','provinceid','cityid'],
        //登录
        //'signin'  =>  ['name' => 'require', 'name' => 'require'],
    ];
}
